07. AMCL Launch File: AMCL Node
AMCL Node
The next node to be set up is the
amcl
node. As it was introduced in the previous concepts, it takes
odometry
and
laser scan
data to perform the AMCL localization.
Add
amcl
Node
First, add the
amcl
node in your
amcl.launch
file:
<launch>
<!-- Map Server -->
...
<!-- AMCL Node -->
<node name="amcl" pkg="amcl" type="amcl" output="screen">
</node>
</launch>
Ok, we created the
amcl
node. However it needs more information to localize the robot! For example, what are the sensor readings from the LiDAR?
Remap
scan
topic
By default,
amcl
package will look for the
scan
topic for LiDAR data. In the simulation, the
Hokuyo
LiDAR sensor actually publishes on the
<YOUR PACKAGE NAME>/laser/scan
topic. We will use the
remap
tag to remap the topic name
scan
to the actual topic name so that the
amcl
package could use it!
Add this
remap
line to your
amcl
node in the
amcl.launch
file:
...
<!-- AMCL Node -->
<node name="amcl" ...>
<remap from="scan" to="<YOUR PACKAGE NAME>/laser/scan"/>
</node>
For more information on
remap
, check out the ROS Wiki here:
http://wiki.ros.org/roslaunch/XML/remap
Add AMCL Parameters
The AMCL node also requires a set of parameters in order to connect the world (
map
frame) with the robot (
odom
frame).
Add the following parameter tags to the
amcl
node in the
amcl.launch
file:
...
<!-- AMCL Node -->
<node name="amcl" ...>
<remap from="scan" to="<YOUR PACKAGE NAME>/laser/scan"/>
<param name="odom_frame_id" value="odom"/>
<param name="odom_model_type" value="diff-corrected"/>
<param name="base_frame_id" value="robot_footprint"/>
<param name="global_frame_id" value="map"/>
</node>
From the ROS Wiki ( http://wiki.ros.org/amcl) , we could find the purpose of the parameters added above:
-
odom_frame_id
(string, default: "odom"): Which frame to use for odometry -
odom_model_type
(string, default: "diff"): Which model to use, either "diff", "omni", "diff-corrected" or "omni-corrected" -
base_frame_id
(string, default: "base_link"): Which frame to use for the robot base -
global_frame_id
(string, default: "map"): The name of the coordinate frame published by the localization system
Remember, AMCL package 'links' the robot (
odom
frame) with the world (
map
frame). These parameters are required for
amcl
package to localize the robot in the world.
Optional: Set Initial Position
You could use the RViz
2D Pose Estimate
function to give AMCL a pose estimate as position, but you could also have it defined in the launch file.
Add the following parameters to the AMCL node, the values should correspond to your
world.launch
file:
<param name="initial_pose_x" value="<YOUR X VALUE>"/>
<param name="initial_pose_y" value="<YOUR Y VALUE>"/>
The Launch File
Now, your
amcl.launch
file should look like this:
<launch>
<!-- Map Server -->
<arg name="map_file" ... />
<node name="map_server" ... />
<!-- AMCL Node -->
<node name="amcl" pkg="amcl" type="amcl" output="screen">
<remap from="scan" to="<YOUR PACKAGE NAME>/laser/scan"/>
<param name="odom_frame_id" value="odom"/>
<param name="odom_model_type" value="diff-corrected"/>
<param name="base_frame_id" value="robot_footprint"/>
<param name="global_frame_id" value="map"/>
<!-- If you choose to define initial pose here -->
<param name="initial_pose_x" value="0"/>
<param name="initial_pose_y" value="0"/>
</node>
</launch>
Now, the robot has a map and the
amcl
package to localize itself. But how could it navigate to other positions to collect more information about its surroundings?
ROS Navigation Stack
is the answer.